@{
    ViewData["Title"] = "列表";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">热门关键词</div>
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-row">
                            <div class="layui-form-item">
                                <div class="layui-col-md2" style="padding-left:0" id="parent">
                                    <input type="hidden" id="ParentCategoryId"  name="categoryId" lay-verify="required" />
                                    <input type="text" id="ParentName" class="layui-input"  placeholder="选择分类" autocomplete="off" lay-verify="required" />
                                </div>
                                <div class="layui-col-md3">
                                    <div class="input-group">
                                        <input type="text" id="keyWords" name="keyWords" placeholder="添加关键字" autocomplete="off" class="layui-input">
                                        <span class="input-group-btn">
                                            <button class="layui-btn" id="add">
                                                添加
                                            </button>
                                        </span>
                                    </div>
                                </div>
                                <div class="layui-col-md3" style="margin-left:50px;">
                                    <div class="input-group">
                                        <input type="text" id="keyWordsSearch" name="keyWords" placeholder="请输入关键字" autocomplete="off" class="layui-input">
                                        <span class="input-group-btn">
                                            <button class="layui-btn" id="search">
                                                <i class="layui-icon layui-icon-search"></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                        <div class="layui-row">
                            <div class="layui-btn-container">
                                <div class="layui-btn-group">
                                    <button class="layui-btn layui-btn-danger" id="deleteAll"><i class="layui-icon">&#xe640;</i>批量删除</button>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <table class="layui-table" lay-data="{page:true, id:'list'}" lay-filter="list">
                                <thead>
                                    <tr>
                                        <th lay-data="{checkbox:true, fixed: true}"></th>
                                        <th lay-data="{ field: 'id',width:100}">关键字ID</th>
                                        <th lay-data="{ field: 'keyWords'}">关键字</th>
                                        <th lay-data="{ field: 'cateName'}">分类名称</th>
                                        <th lay-data="{toolbar:'#tableoption',align:'center',width:100}">操作</th>
                                    </tr>
                                </thead>
                            </table>
                            <script type="text/html" id="tableoption">
                                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                            </script>
                        </div>
                    </div>
                </div>
        </div>
    </div>
</div>
@section scriptsfeet
{
<script type="text/javascript">
        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['sykjwh', 'table'], function () {
            var $ = layui.$, sykjwh = layui.sykjwh, table = layui.table;

            //绑定数据
            sykjwh.dataBind('@Url.Action("HotKeyWordsList", "Ms", new { area = Constant.AREAMANAGER })');
            
            //批量删除
            $("#deleteAll").click(function () {
                sykjwh.batOperate('@Url.Action("HotKeyWordsDeleteAll", "Ms", new { area = Constant.AREAMANAGER })', 'id');
            });

            //监听表格行
            table.on('tool(list)', function (obj) {
                var data = obj.data;//获得当前行数据
                if (obj.event === 'edit') {
                    sykjwh.openFull('编辑', '@Url.Action("HotKeyWordsEdit", "Ms", new { area = Constant.AREAMANAGER })/' + data.id);
                }
            });

            $("#parent").click(function () {
                sykjwh.open('商品分类', '@Url.Action("CategoriesTreeList", "Ms", new {area = Constant.AREAMANAGER})', 400, 550);
            });

            //搜索
            $("#search").click(function () {
                //绑定数据
                sykjwh.dataBind('@Url.Action("HotKeyWordsList", "Ms", new { area = Constant.AREAMANAGER })', {
                    keyWordsSearch: $.trim($("#keyWordsSearch").val())
                });
            });

            //添加
            $("#add").click(function () {
                sykjwh.request("@Url.Action("HotKeyWordsAdd", "Ms", new { area = Constant.AREAMANAGER })?CategoryId=" + $("#ParentCategoryId").val() + "&KeyWords=" + $("#keyWords").val(),"POST");
                //绑定数据
                sykjwh.dataBind('@Url.Action("HotKeyWordsList", "Ms", new { area = Constant.AREAMANAGER })', {
                    keyWords: $.trim($("#keyWords").val())
                });
            });
        });
</script>
}